import os
import json
from conf.settings import CART_JSON_PATH
from loguru import logger

def loads_cart_json():
    cart = []
    if os.path.exists(CART_JSON_PATH):
        with open(CART_JSON_PATH, "r", encoding="utf-8") as f:
            cart = json.load(f)
        logger.info(f"{CART_JSON_PATH}加载成功！")
    return cart

def save_cart(cart):
    with open(CART_JSON_PATH, "w", encoding="utf-8") as f:
        # json.dumps()
        json.dump(cart, f)